package org.example.strategy;

/**
 * @author Zhang Yu
 * @description: TODO
 * @date 2024/5/20 14:20
 */
public class CashContext {
    private CashSuper cs;

    public CashContext(CashSuper cs) {
        this.cs = cs;
    }

    public CashContext(String strategy) {
        switch (strategy) {
            case "正常收费":
                cs = new CashNormal();
                break;
            case "满300减100":
                cs = new CashReturn(300, 100);
                break;
            case "打8折":
            default:
                cs = new CashRebate(0.8);
                break;
        }
    }

    public double getResult(double money) {
        return cs.acceptCash(money);
    }

}
